<template>
  <div class="store-wrap">
    <store-info-item :storeInfo="storeInfo" />
    <a-space>
      <a-button type="primary" @click="$refs.douyin.show();id=storeInfo.id;is_join=storeInfo.is_join">是否参加抖音活动</a-button>
      <a-button type="primary" @click="$refs.storePrice.show()" v-if='userInfo.type === 1'>续费</a-button>
      <a-button type="primary" @click="onGoWallet">概况</a-button>
      <a-button type="primary" v-if="storeInfo.status === 1" @click="downFall">审核驳回</a-button>
      <a-button type="primary" v-else @click="putAway">审核通过</a-button>
    </a-space>

    <storePrice ref="storePrice" :sid="storeInfo.id" @change="change()"/>
    <douyin ref="douyin" :sid="id" @change="change()" :is_join="is_join"/>
  </div>
</template>

<script>
import StoreInfoItem from '@/components/StoreInfoItem'
import storePrice from './storePrice'
import { storePutaway, storeDownfall } from '@/api/store'
import {mapGetters} from "vuex";
import douyin from '@/views/wallet/modules/douyin.vue'

export default {
  components: {
    StoreInfoItem,
    storePrice,
    douyin
  },
  props: {
    storeInfo: {
      type: Object,
      default: () => {}
    },
    storeType: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      id: '',
      is_join: ''
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  methods: {
    change(){
      this.$emit('check')
    },
      onGoWallet () {
          this.$router.push({
              name: 'storeStat',
              query: {
                  type: this.storeType,
                  id: this.storeInfo.id
              }
          })
      },
    downFall () {
      this.$confirm({
        title: '您确定要进行审核驳回吗?',
        content: h => <div style="color:red">驳回后该门店将停止营业</div>,
        okType: 'danger',
        okText: '驳回',
        onOk: () => {
          const params = {
            id: this.storeInfo.id,
            type: this.storeType
          }
          return storeDownfall(params).then(res => {
            this.$message.success('操作成功')
            this.$emit('check')
          })
        }
      })
    },
    putAway () {
      this.$confirm({
        title: '您确定要进行审核通过吗?',
        content: `审核后该门店将开始营业`,
        onOk: () => {
          const params = {
            id: this.storeInfo.id,
            type: this.storeType
          }
          return storePutaway(params).then(res => {
            this.$message.success('操作成功')
            this.$emit('check')
          })
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.store-wrap {
  display: flex;
  align-items: flex-end;
  .store-container {
    flex: 1;
  }
  .earning-btn {
    padding: 0 25px;
  }
}
</style>
